显示图片
1)打开booktest/views.py文件,创建视图pic_show。
from booktest.models import PicTest
...
def pic_show(request):
pic=PicTest.objects.get(pk=1)
context={'pic':pic}
return render(request,'booktest/pic_show.html',context)
2)打开booktest/urls.py文件,配置url。
url(r'^pic_show/$', views.pic_show),
3)在templates/booktest/目录下创建模板pic_show.html。
显示上传的图片
4)运行服务器,在浏览器中输入如下网址:
http://127.0.0.1:8000/pic_show/